<script setup lang="ts">
import Panel from 'primevue/panel';
import Textarea from 'primevue/textarea';
import Button from 'primevue/button';
import { reactive, ref } from 'vue';
import axios from 'axios';

const answer = ref('');
const api = axios.create({
    baseURL: 'https://www.scnet.cn/acx/chatbot/v1/chat/completion',
    timeout: 1000,
});

const conversation = reactive({
    conversationId: "1898963733892640770",
    content: "",
    thinking: 0,
    online: 0,
    modelId: 2
})
const submit = () => {
    api.post('/', conversation).then((res) => {

        console.log(res);
    }).catch((err) => {
        console.log(err);
    });
};

</script>

<template>
    <div class="ai">
        <Panel header="Answer">
            <p>{{ answer }}</p>
        </Panel>
        <Textarea placeholder="提出您想要知道的问题" v-model="conversation.content" rows="5" cols="30" class="input__text" />
        <Button label="提交" class="submit__btn" @click="submit" />
    </div>
</template>

<style scoped>
.input__text {
    width: 100%;
    height: 200px;
}

.submit__btn {
    float: right;
}
</style>